package com.coollang.smartbra.utils;

import com.coollang.smartbra.R;
import com.coollang.smartbra.base.MyApplication;
import com.coollang.smartbra.constant.Constants;
import com.coollang.smartbra.interfaces.ActionType;

import java.util.Random;

/**
 * @author : Timmy
 * @data : 2017/12/16
 * @Fuction : 运动解析类, 获取语音,错误信息
 */
public class ActionTypeParse {

    private static MyApplication getContext() {
        return MyApplication.getApplication();
    }


    /**
     * U币个数获取
     */
    public static String getActionName(int actionCode) {
        String actionName;
        switch (actionCode) {
            case ActionType.RUNNING:
                actionName = "跑步";
                break;
            case ActionType.WALK:
                actionName = "步行";
                break;
            case ActionType.SDT:
                actionName = "深蹲跳";
                break;
            case ActionType.YWQZ:
                actionName = "仰卧起坐";
                break;
            case ActionType.JF:
                actionName = "卷腹";
                break;
            case ActionType.FWC:
                actionName = "俯卧撑";
                break;
            case ActionType.PBZC:
                actionName = "平板支撑";
                break;
            case ActionType.TQ:
                actionName = "臀桥";
                break;
            case ActionType.ZQ:
                actionName = "直桥";
                break;
            case ActionType.LTQ:
                actionName = "两头起";
                break;
            case ActionType.XFY:
                actionName = "小飞燕";
                break;
            case ActionType.ZZST:
                actionName = "坐姿收腿";
                break;
            case ActionType.JFZYMJ:
                actionName = "卷腹左右摸脚";
                break;
            default:
                actionName = "";
                break;
        }
        return actionName;
    }


    /**
     * 获取正确或者错误的语音类型
     *
     * @param errorType 对应的编号
     *                  -1代表正确的动作
     */
    public static int getActionVoice(int actionType, int errorType) {
        errorType--;
        int voiceID;
        try {
            switch (actionType) {
                case -1:
                    // 正确
                    voiceID = Constants.ACTION_CORRECT_VOICE[new Random().nextInt(3)];
                    break;
                case 0:
                    voiceID = Constants.SDT_ERROR_VOICE[errorType];
                    break;
                case 1:
                    voiceID = Constants.YWQZ_ERROR_VOICE[errorType];
                    break;
                case 2:
                    voiceID = Constants.JF_ERROR_VOICE[errorType];
                    break;
                case 3:
                    // voiceID = Constants.FWC_ERROR_VOICE[errorType];
                    voiceID = Constants.PBZC_ERROR_VOICE[errorType];
                    break;
                case 4:
                    voiceID = Constants.TQ_ERROR_VOICE[errorType];
                    break;
                case 5:
                    voiceID = Constants.ZQ_ERROR_VOICE[errorType];
                    break;
                case 6:
                    voiceID = Constants.LTQ_ERROR_VOICE[errorType];
                    break;
                case 7:
                    voiceID = Constants.XFY_ERROR_VOICE[errorType];
                    break;
                case 8:
                    voiceID = Constants.ZJST_ERROR_VOICE[errorType];
                    break;
                case 9:
                    voiceID = Constants.JFZYMJ_ERROR_voice[errorType];
                    break;
                case 10:
                    voiceID = Constants.JFZYMJ_ERROR_voice[errorType];
                    break;
                default:
                    voiceID = 0;
                    break;
            }
        } catch (Exception e) {
            voiceID = 0;
        }
        return voiceID;
    }

    /**
     * 获取错误动作详情
     */
    public static String parseErrorType(int actionType, int errorType) {
        errorType--;
        String errorInfo;
        try {
            switch (actionType) {
                case 0:
                    errorInfo = Constants.SDT_ERROR_INFO[errorType];
                    break;
                case 1:
                    errorInfo = Constants.YWQZ_ERROR_INFO[errorType];
                    break;
                case 2:
                    errorInfo = Constants.JF_ERROR_INFO[errorType];
                    break;
                case 3:
                    // errorInfo = Constants.FWC_ERROR_INFO[errorType];
                    errorInfo = Constants.PBZC_ERROR_INFO[errorType];
                    break;
                case 4:
                    errorInfo = Constants.TQ_ERROR_TYPE[errorType];
                    break;
                case 5:
                    errorInfo = Constants.ZQ_ERROR_TYPE[errorType];
                    break;
                case 6:
                    errorInfo = Constants.LTQ_ERROR_TYPE[errorType];
                    break;
                case 7:
                    errorInfo = Constants.XFY_ERROR_TYPE[errorType];
                    break;
                case 8:
                    errorInfo = Constants.ZJST_ERROR_TYPE[errorType];
                    break;
                case 9:
                    errorInfo = Constants.JFZYMJ_ERROR_TYPE[errorType];
                    break;
                default:
                    errorInfo = "未知错误";
                    break;
            }
        } catch (Exception e) {
            errorInfo = "未知错误";
        }
        return errorInfo;
    }


    /**
     * 根据运动code 获取运动计划对应的图片资源
     */
    public static int getActionPlanDrawable(int actionCode) {
        int planDrawable = 0;
        switch (actionCode) {
            case ActionType.RUNNING:
                planDrawable = R.drawable.plan_run;
                break;
            case ActionType.WALK:
                planDrawable = R.drawable.plan_walk;
                break;
            case ActionType.SD:
                planDrawable = R.drawable.plan_sd;
                break;
            case ActionType.SDT:
                planDrawable = R.drawable.plan_sdt;
                break;
            case ActionType.YWQZ:
                planDrawable = R.drawable.plan_ywqz;
                break;
            case ActionType.JF:
                planDrawable = R.drawable.plan_jf;
                break;
            case ActionType.FWC:
                planDrawable = R.drawable.plan_fwc;
                break;
            case ActionType.PBZC:
                planDrawable = R.drawable.plan_pbzc;
                break;
            case ActionType.TQ:
                planDrawable = R.drawable.plan_tq;
                break;
            case ActionType.ZQ:
                planDrawable = R.drawable.plan_zq;
                break;
            case ActionType.LTQ:
                planDrawable = R.drawable.plan_ltq;
                break;
            case ActionType.XFY:
                planDrawable = R.drawable.plan_xfy;
                break;
            case ActionType.ZZST:
                planDrawable = R.drawable.plan_zzst;
                break;
            case ActionType.JFZYMJ:
                planDrawable = R.drawable.plan_jfzymj;
                break;
            default:
                planDrawable = R.drawable.plan_walk;
                break;
        }
        return planDrawable;
    }

    /**
     * 分享页面小图标获取
     */
    public static int getShareDrawable(int actionCode) {
        int shareDrawable = 0;
        switch (actionCode) {
            case ActionType.RUNNING:
                shareDrawable = R.drawable.share_fwc;
                break;
            case ActionType.WALK:
                shareDrawable = R.drawable.share_fwc;
                break;
            case ActionType.SDT:
                shareDrawable = R.drawable.share_sdt;
                break;
            case ActionType.YWQZ:
                shareDrawable = R.drawable.share_ywqz;
                break;
            case ActionType.JF:
                shareDrawable = R.drawable.share_jf;
                break;
            case ActionType.FWC:
                shareDrawable = R.drawable.share_fwc;
                break;
            case ActionType.PBZC:
                shareDrawable = R.drawable.share_pbzc;
                break;
            case ActionType.TQ:
                shareDrawable = R.drawable.share_tq;
                break;
            case ActionType.ZQ:
                shareDrawable = R.drawable.share_zq;
                break;
            case ActionType.LTQ:
                shareDrawable = R.drawable.share_ltq;
                break;
            case ActionType.XFY:
                shareDrawable = R.drawable.share_xfy;
                break;
            case ActionType.ZZST:
                shareDrawable = R.drawable.share_zjst;
                break;
            case ActionType.JFZYMJ:
                shareDrawable = R.drawable.share_jfzymj;
                break;
            default:
                shareDrawable = R.drawable.share_fwc;
                break;
        }
        return shareDrawable;
    }

    /**
     * U币个数获取
     */
    public static int getUMoneyCount(int actionCode) {
        int moneyCount = 0;
        switch (actionCode) {
            case ActionType.RUNNING:
                moneyCount = 2;
                break;
            case ActionType.WALK:
                moneyCount = 1;
                break;
            case ActionType.SDT:
                moneyCount = 21;
                break;
            case ActionType.YWQZ:
                moneyCount = 10;
                break;
            case ActionType.JF:
                moneyCount = 10;
                break;
            case ActionType.FWC:
                moneyCount = 27;
                break;
            case ActionType.PBZC:
                moneyCount = 8;
                break;
            case ActionType.TQ:
                moneyCount = 17;
                break;
            case ActionType.ZQ:
                moneyCount = 23;
                break;
            case ActionType.LTQ:
                moneyCount = 22;
                break;
            case ActionType.XFY:
                moneyCount = 27;
                break;
            case ActionType.ZZST:
                moneyCount = 25;
                break;
            case ActionType.JFZYMJ:
                moneyCount = 25;
                break;
            default:
                moneyCount = 0;
                break;
        }
        return moneyCount;
    }

}
